package com.demo01.service.impl;

import com.demo01.dao.User2Dao;
import com.demo01.pojo.User2;
import com.demo01.service.User2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("user2Service")
public class User2ServiceImpl implements User2Service {
    @Autowired
    User2Dao user2Dao;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void addRequired(User2 user2) {
        user2Dao.insert(user2);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void addRequiredException(User2 user2) {
        user2Dao.insert(user2);
        throw new RuntimeException("运行时期异常");
    }


}
